package com.kili.file.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


/**
 * FileMagicNumType
 *
 * @author Gordon
 * @version 2019/3/27
 */
public enum FileMagicNumType {
    /**
     * The hexadecimal number of each type of file
     */
    JPG("jpg", "FFD8FF"),
    PNG("png", "89504E47"),
    GIF("gif", "47494638"),
    //    TIF("tif", "49492A00"),
//    BMP("bmp", "424D"), //Windows Bitmap (bmp)
//    DWG("dwg", "41433130"), //CAD (dwg)
    HTML("html", "68746D6C3E"),
    DOC("doc", "D0CF11E0"),  //MS Excel Note: word is the same as the file header of excel
    DOCX("docx", "504B0304"),
    PDF("pdf", "255044462D312E"), //Adobe Acrobat (pdf)
    XLS("xls", "D0CF11E0"),  //MS Word
    XLSX("xlsx", "504B0304140006000"),
    PS("ps", "252150532D41646F6265"),
    RTF("rtf", "7B5C727466"),  //Rich Text Format (rtf)

    //unable to check magic number
    TXT("txt", ""),
    APK("apk", ""),
    CSS("css", ""),

//    XML("xml", "3C3F786D6C"),
    ZIP("zip", "504B0304"),
//    RAR("rar", "52617221"),
//    PSD("psd", "38425053"),  //Photoshop (psd)
//    EML("eml", "44656C69766572792D646174653A"),  //Email [thorough only] (eml)
//    DBX("dbx", "CFAD12FEC5FD746F"),  //Outlook Express (dbx)
//    PST("pst", "2142444E"),  //Outlook (pst)
//    //    MDB("mdb", "5374616E64617264204A"),  //MS Access (mdb)
//    //    WPD("wpd", "FF575043"), //WordPerfect (wpd)
//    EPS("eps", "252150532D41646F6265"),
//    QDF("qdf", "AC9EBD8F"),  //Quicken (qdf)
//    PWL("pwl", "E3828596"),  //Windows Password (pwl)
//    WAV("wav", "57415645"),  //Wave (wav)
//    AVI("avi", "41564920"),
//    RAM("ram", "2E7261FD"),  //Real Audio (ram)
//    RM("rm", "2E524D46"),  //Real Media (rm)
//    MPG("mpg", "000001BA"),  //
//    MOV("mov", "6D6F6F76"),  //Quicktime (mov)
//    ASF("asf", "3026B2758E66CF11"), //Windows Media (asf)
//    MID("mid", "4D546864");  //MIDI (mid)
    ;
    private String type;
    private String hex;

    FileMagicNumType(String type, String hex) {
        this.type = type;
        this.hex = hex;
    }

    public static final Map<String, String> FILE_HEX_MAP = new HashMap<>();


    public String getType() {
        return type;
    }

    public String getHex() {
        return hex;
    }

    static {
        FileMagicNumType[] var0 = values();
        Arrays.asList(var0).forEach((var) -> FILE_HEX_MAP.put(var.type, var.hex));

    }
}
